package ws.sentiment;

import model.Pair;
import model.oanda.Order;
import play.Logger;

public class SentimentFilter {

	public static final int limit=55;
	
	public static boolean filter(Pair pair){
		
		if(pair.sentiment>=limit){		
			Logger.debug(String.format(
				 "Sentiment positive for %s: %d",
				 pair.name,pair.sentiment));
			
			pair.side=Order.BUY;
			
			return true;
		}
		
		if(pair.sentiment<=(100-limit)){		
			Logger.debug(String.format(
				 "Sentiment negative for %s: %d",
				 pair.name,100-pair.sentiment));
			
			pair.side=Order.SELL;
			 
			return true;
		}
		
		return false;
	}
	
//	public static List<Pair> filter(List<Pair> pairs){
//		
//		List<Pair> result=new ArrayList<Pair>(pairs.size());
//		
//		for(Pair p: pairs){
//			if(filter(p)){
//				result.add(p);
//			}
//		}
//		
//		return result;
//			
//	}
	
	

//	public static long sentiment1(WSResponse response) throws IOException {
//
//		List<Pair> p = Arrays.asList(new Pair("111", "EUR/USD"), new Pair(
//				"112", "GBP/USD"), new Pair("113", "USD/JPY"), new Pair("114",
//				"USD/CHF"), new Pair("115", "AUD/USD"), new Pair("116",
//				"USD/CAD"), new Pair("170", "EUR/GBD"), new Pair("171",
//				"EUR/JPY"), new Pair("172", "GBP/JPY"));
//
//		return p.parallelStream().map(pair -> SentimentPair.pair(response, pair))
//				.filter(pair->filter(pair)).count();
//
//		// return
//		// .parallelStream().map(pair -> {
//		// return ;
//		// }).findFirst().get();
//	}
	// public static WSResponse EUR_USD_SENTIMENT(WSResponse response)
	// throws IOException {
	// return sentiment(
	// response,
	// "https://www.stockpair.com/trading/trading?pairId=111&snippet&li",
	// "EUR/USD");
	// }

	/*
	 * public static WSResponse GBP_USD_SENTIMENT(WSResponse response) throws
	 * IOException { return sentiment( response,
	 * "https://www.stockpair.com/trading/trading?pairId=112&snippet&li",
	 * "GBP/USD"); }
	 * 
	 * public static WSResponse GBP_USD_SENTIMENT(WSResponse response) throws
	 * IOException { return sentiment( response,
	 * "https://www.stockpair.com/trading/trading?pairId=112&snippet&li",
	 * "GBP/USD"); }
	 * 
	 * public static WSResponse GBP_USD_SENTIMENT(WSResponse response) throws
	 * IOException { return sentiment( response,
	 * "https://www.stockpair.com/trading/trading?pairId=112&snippet&li",
	 * "GBP/USD"); }
	 * 
	 * public static WSResponse GBP_USD_SENTIMENT(WSResponse response) throws
	 * IOException { return sentiment( response,
	 * "https://www.stockpair.com/trading/trading?pairId=112&snippet&li",
	 * "GBP/USD"); }
	 * 
	 * public static WSResponse GBP_USD_SENTIMENT(WSResponse response) throws
	 * IOException { return sentiment( response,
	 * "https://www.stockpair.com/trading/trading?pairId=112&snippet&li",
	 * "GBP/USD"); }
	 */
}